package com.example.lib.muchthread;

/**
 * 原来线程都有自己的默认名称
 * Thread-编号，该编号从0开始。
 *
 * static Thread currentThread():获取当前线程对象。
 * getName():获取线程名称
 *
 * 设置线程名称：setName或者构造函数。
 *
 */

public class d_Thread_name_132 {

    public static void main(String[] args) {
        Test132 thread1 = new Test132("one---");
        Test132 thread2 = new Test132("two---");
        thread1.start();
        thread2.start();
//        thread1.run();
//        thread2.run();
        for (int i = 0; i < 60; i++) {
            System.out.println("main----" + i);
        }
    }
}

class Test132 extends Thread {
//    private String name;

    public Test132(String name) {
//        this.name = name;
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 60; i++) {
//            System.out.println(this.getName()+" Test run---"+i);
//            System.out.println(Thread.currentThread().getName()+" Test run---"+i);
            System.out.println((Thread.currentThread() == this) + "..." + this.getName() + " Test run---" + i);
        }
    }
}
